import {Observable} from 'rxjs';
import {Injectable} from '@angular/core';
import {HttpService} from '../../httpService';


@Injectable({
  providedIn: 'root'
})

export class EquipMgmtServices {
  http: any;
  private API_LIST: any;

  constructor(private Http: HttpService) {
    this.http = Http;
    this.API_LIST = {
      GET_ALL_LINE: `http://${this.http.currentHost}:8080/system-management/line/queryall`,
      GET_ALL_SITE_BY_LINE_ID: `http://${this.http.currentHost}:8080/system-management/site/querybylineid`,
      GET_ALL_INSTANCE_BY_SITE_ID: `http://${this.http.currentHost}:8080/portal/device-site-relation/querydevicebysiteid`,
      GET_ALL_INSTANCE_INFO: `http://${this.http.currentHost}:8080/device/device/querydeviceall`
    };
  }


  public getAllLine(): Observable<any> {
    return this.http.post(this.API_LIST.GET_ALL_LINE, {}, {});
  }

  public getSiteByLineId(lineId): Observable<any> {
    return this.http.get(this.API_LIST.GET_ALL_SITE_BY_LINE_ID + `/${lineId}`);
  }

  public getInstanceBySiteId(siteId): Observable<any> {
    return this.http.post(this.API_LIST.GET_ALL_INSTANCE_BY_SITE_ID + `/${siteId}`);
  }

  public getInstanceAllInfo(deviceId, deviceDefId, attrDefCatCode): Observable<any> {
    return this.http.post(this.API_LIST.GET_ALL_INSTANCE_INFO + `/${deviceId}/${deviceDefId}`, {
      id: deviceId,
      deviceDefId,
      attrDefCatCode
    }, {});
  }
}




